﻿using System.Data.Common;
using System.Data.SqlClient;
using MySql.Data.MySqlClient;
using Zinnia.Lite.Configs;
using Zinnia.Lite.Driver;
using Zinnia.Lite.Untilty;

namespace Zinnia.MySql.Driver
{
    /// <summary>
    /// MYSql数据库驱动
    /// </summary>
    public class MySqlDriver : IDriver
    {
        public DbConnection GetDbConnection(StorageConfig config)
        {
            return new MySqlConnection
            {
                ConnectionString = $"Server={config.DataSource};Stmt=;Database={config.InitialCatalog}; User={config.UserId};Password={DesEncryptHelper.Instance.Decrypt(config.Password, "0845d1a5")};"
                //ConnectionString = $"Data Source={config.DataSource}; Initial Catalog={config.InitialCatalog}; User ID={config.UserId}; Password={DesEncryptHelper.Instance.Decrypt(config.Password, "0845d1a5")}; MultipleActiveResultSets=True"
            };
        }
    }
}
